package com.fly.common;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;

import org.apache.commons.lang.SystemUtils;
import org.apache.log4j.Logger;

@WebServlet(value = {"/start"}, loadOnStartup = 1)
public class Startup extends HttpServlet
{
    
    private static final Logger LOGGER = Logger.getLogger(Startup.class);
    
    /**
     * 注释内容
     */
    private static final long serialVersionUID = -5156345638165284301L;
    
    /**
     * 打开浏览器
     * 
     * @see [类、类#方法、类#成员]
     */
    @Override
    public void init()
        throws ServletException
    {
        try
        {
            if (SystemUtils.IS_OS_WINDOWS)
            {
                LOGGER.info("now open Browser...");
                Runtime.getRuntime().exec("cmd.exe /c start /min http://127.0.0.1:8080/");
            }
        }
        catch (IOException e)
        {
            throw new ServletException(e.getMessage(), e.getCause());
        }
    }
}